package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.FactoryMapper;
import com.lx.oms.controller.entity.FactoryEntity;
import com.lx.oms.controller.manager.FactoryManager;

/**
 * 厂名
 *
 * @author houzhong
 * @date 2018年10月24日 下午1:26:13
 */
@Component("factoryManager")
public class FactoryManagerImpl implements FactoryManager {

	@Autowired
	private FactoryMapper factoryMapper;
	

	@Override
	public List<FactoryEntity> listFactory(Page<FactoryEntity> page, Query search) {
		return factoryMapper.listForPage(page, search);
	}

	@Override
	public int saveFactory(FactoryEntity factory) {
		if (factory.getId() == null) {
			factory.setId(Utils.id().toString());
		}
		return factoryMapper.save(factory);
	}

	@Override
	public FactoryEntity getFactoryById(BigInteger id) {
		FactoryEntity tFactory = factoryMapper.getObjectById(id);
		return tFactory;
	}

	@Override
	public int updateFactory(FactoryEntity factory) {
		return factoryMapper.update(factory);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = factoryMapper.batchRemove(id);
		return count;
	}

	@Override
	public FactoryEntity getFactoryByName(String name) {
		FactoryEntity tFactory = factoryMapper.getFactoryByName(name);
		return tFactory;
	}

	@Override
	public List<FactoryEntity> listByFactory(Query query) {

		return factoryMapper.listByFactory(query);
	}
	
}
